#region Imports

using System;
using d3PrtDgn.Core.BaseData;

#endregion

namespace d3PrtDgn.Data.Domain.Entity
{
	[Serializable]
    public class Vote : BaseEntity
	{
		#region Private Members

		// Primary Key(s) 
		private int id; 
		
		// Foreign Keys mappate come Many-To-One 
		private Photo photo; 
		private User user; 
		
		// Properties 
		private DateTime inserted; 
		private byte rating; 		

		#endregion
		
		#region Default ( Empty ) Class Constructor
		
		/// <summary>
		/// default constructor
		/// </summary>
		public Vote()
		{
			id = 0; 
			photo = null; 
			user = null; 
			inserted = DateTime.MinValue; 
			rating = 0; 
		}
		
		#endregion // End of Default ( Empty ) Class Constructor
		
		#region Full Constructor
		
		/// <summary>
		/// full constructor
		/// </summary>
		public Vote(int id, Photo idphoto, User iduser, DateTime inserted, byte votename)
		{
			this.id = id;
			this.photo = idphoto;
			this.user = iduser;
			this.inserted = inserted;
			this.rating = votename; 
		}
		
		#endregion // End Full Constructor

		#region Public Properties
			
		/// <summary>
		/// Unique identifier
		/// </summary>		
		public virtual int Id
		{
			get { return id; }
			set { isChanged |= (id != value); id = value; }
		} 
	  
		/// <summary>
		/// Photo which contains this vote
		/// </summary>		
		public virtual Photo Photo
		{
			get { return photo; }
			set { isChanged |= (photo != value); photo = value; }
		} 
	  
		/// <summary>
		/// User who voted
		/// </summary>		
		public virtual User User
		{
			get { return user; }
			set { isChanged |= (user != value); user = value; }
		} 
	  
		/// <summary>
		/// Date when voted
		/// </summary>		
		public virtual DateTime Inserted
		{
			get { return inserted; }
			set { isChanged |= (inserted != value); inserted = value; }
		} 
	  
		/// <summary>
		/// Vote from 1 (worst) to 5 (best) stars
		/// </summary>		
		public virtual byte Rating
		{
			get { return rating; }
			set { isChanged |= (rating != value); rating = value; }
		} 
	  
		/// <summary>
		/// Returns whether or not the object has changed it's values.
		/// </summary>
		public virtual bool IsChanged
		{
			get { return isChanged; }
		}
		
		/// <summary>
		/// Returns whether or not the object has changed it's values.
		/// </summary>
		public virtual bool IsDeleted
		{
			get { return isDeleted; }
		}
		
		#endregion 
		
        #region Public Functions

        #endregion

		#region Equals And HashCode Overrides
		
		/// <summary>
		/// local implementation of Equals based on unique value members
		/// </summary>
		public override bool Equals( object obj )
		{
			if( this == obj ) return true;
			if( ( obj == null ) || ( obj.GetType() != this.GetType() ) ) return false;
			Vote castObj = (Vote)obj; 
			return ( castObj != null ) &&
				( this.id == castObj.Id );
		}
		
		/// <summary>
		/// local implementation of GetHashCode based on unique value members
		/// </summary>
		public override int GetHashCode()
		{ 
			int hash = 57; 
			hash = 27 * hash * this.id.GetHashCode();
					
			return hash;		
			
		}
		
		#endregion
		
	}
}